package zy;

import java.util.Arrays;
import java.util.Scanner;

public class zy1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        /*
        1、使用二维数组存储班上五个学生三门功课的考试成绩，要求输出每一个学生的总分、平均分、最高分、最低分
        * */
//        int[][] score = new int[5][3];
//        String[] coures = {"C#","Java","HTML"};
//        double sum,avg,max,min;
//        sum=avg=max=min=0.0;
//        for (int i = 0; i < score.length; i++) {
//            sum = 0.0;
//            System.out.println("请输入第"+(i+1)+"位同学的成绩:");
//            for (int j = 0; j < score[i].length; j++) {
//                System.out.print(coures[j]+"的成绩是:");
//                score[i][j] = input.nextInt();
//                sum += score[i][j];
//                avg = sum/coures.length;
//
//                if (score[i][j]>max){
//                    max = score[i][j];
//                }
//                if (j==1){
//                    min=score[i][j];
//                }
//                if (score[i][j]<min){
//                    min=score[i][j];
//                }
//            }
//            System.out.println("总分:"+sum+",平均分:"+avg+",最高分:"+max+",最低分:"+min);
//        }

        /*
        3、静态初始化一维数组{10,20,11,35,6,89}，进行冒泡排序
        * */
//        int[] numbers = {10,20,11,35,6,89};
//        for (int i = 0; i < numbers.length-1; i++) {
//            for (int j = 0; j < numbers.length-1-i; j++) {
//                if (numbers[i]>numbers[j+1]){
//                    int temp = numbers[j+1];
//                    numbers[j+1] = numbers[i];
//                    numbers[i] = temp;
//                }
//            }
//            System.out.println(Arrays.toString(numbers));
//        }

        /*
        6、输入五种水果的英文名称(如葡萄grape，橘子orange，香蕉banana，苹果apple，桃peach)，
            编写一个程序，输出这些水果的名称(按照在字典里出现的先后顺序输出)
        * */
//        String[] fruits = {"grape","orange","banana","apple","peach"};
//        for (int i = 0; i < fruits.length; i++) {
//            System.out.print("请输入第"+(i+1)+"个水果的名字:");
//            fruits[i] = input.next();
//        }
//        Arrays.sort(fruits);
//        System.out.println(Arrays.toString(fruits));

        /*
        7、int[] arr11 = {1,2,3,4,5,6,7,8,9,0,3,2,4,5,6,7,4,32,2,1,1,4,6,3}; 数组去重
        * */
        int[] number = {1,2,3,4,5,6,7,8,9,0,3,2,4,5,6,7,4,32,2,1,1,4,6,3};
        int[] numbers = new int[number.length];
        int a = 0;
        for (int i = 0; i < number.length; i++) {
            boolean flag = false;
            for (int j = 0; j < numbers.length; j++) {
                if (number[i]==numbers[j]){
                    flag = true;
                    break;
                }
            }
            if (!flag){
                numbers[a++]=number[i];
            }
        }
        int[] newArr = new int[a];//a表示过滤重复数组长度
        for (int i = 0; i < newArr.length; i++) {
            newArr[i] = numbers[i];
        }
        System.out.println(Arrays.toString(newArr));
    }
}
